import requests
from bs4 import BeautifulSoup


headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
}


url = 'http://www.pxc.jx.cn/'

try:

    response = requests.get(url, headers=headers)
    response.encoding = 'utf-8'  # 设置编码


    if response.status_code == 200:

        with open('D:\\萍乡学院.html', 'w', encoding='utf-8') as f:
            f.write(response.text)
        print("页面已成功保存到 D:\\萍乡学院.html")
    else:
        print(f"请求失败，状态码: {response.status_code}")

except Exception as e:
    print(f"发生错误: {e}")